package com.kejiguan.ui.dialog;

import android.content.Context;

import com.kejiguan.ui.R;
import com.kejiguan.ui.model.MenuItem;
import com.kejiguan.ui.model.UserManagerModer;

import java.util.List;

/**
 * Created by YYY on 2016/5/1.
 */
public class ModifyUserDialogUtil {

    private static ModifyUserDialogUtil instance;
    private ModifyUserDialog modifyUserDialog;

    public ModifyUserDialogUtil() {
    }

    public static ModifyUserDialogUtil getInstance() {
        if (instance == null) {
            synchronized (ModifyUserDialogUtil.class) {
                if (instance == null) {
                    instance = new ModifyUserDialogUtil();
                }
            }
        }
        return instance;
    }

    public void show(Context context,List<MenuItem> menuItems,UserManagerModer userManagerModer,ModifyUserDialog.OnUserModifyListener onUserModifyListener)
    {
        if (null==modifyUserDialog||!modifyUserDialog.isShowing())
        {
            modifyUserDialog=new ModifyUserDialog(context, R.style.dialog_tran);
        }

        modifyUserDialog.withMenus(menuItems).withUser(userManagerModer).withOnUserModifyListener(onUserModifyListener).show();
        modifyUserDialog.setCanceledOnTouchOutside(true);
    }


    public void dismiss()
    {
        if (null!=modifyUserDialog&&modifyUserDialog.isShowing())
        {
            modifyUserDialog.dismiss();
        }
    }
}
